    <link rel="stylesheet" href="css/report/style.css" type="text/css" />
    <script type="text/javascript" src="js/report/char.js"></script>
    <title>票付通旅游营销平台</title>
    <div class="conWrap">
        <div class="topNav">
            <a class="navList active" href="javascript:;" data-type="sale">销售报表</a>
            <a class="navList" href="javascript:;" data-type="buy">采购报表</a>
            <a class="navList" href="http://www.12301.cc/orderReport_Com.html" data-type="sale">数据罗盘</a>
            <a class="navList" href="http://www.12301.cc/orderReport.html" >已卖出产品报表</a>
            <a class="navList" href="http://www.12301.cc/buyOrderReport.html" >已买到产品报表</a>
        </div>
        <form>
        <input type="hidden" name="xtimes" value="3">
        <div class="iConWrap">
            <ul>
                <li class="iList">
                    <div class="leadTxt">完成时间：</div>
                    <div class="datebox" style="margin-left: 130px;">
                        <input id="op" name="begintime" class="inputText2 date controls Wdate" type="text" autocomplete="off" onFocus="WdatePicker({dateFmt:'yyyy-M-d',startDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\'ed\')||\'2020-10-01\'}'})" value="<?=$_REQUEST['begintime']?>"/> 
                        <span>至</span>
                        <input id="ed" name="endtime" class="inputText2 date controls Wdate" type="text" autocomplete="off" onFocus="WdatePicker({dateFmt:'yyyy-M-d',startDate:'%y-%M-%d',minDate:'#F{$dp.$D(\'op\')}',maxDate:'2020-10-01'})" value="<?=$_REQUEST['endtime']?>"/>
                    </div>
                    <div class="timeBox">
                        <a class="timeList today" href="javascript:void(0)">今天</a>
                        <a class="timeList yesterday" href="javascript:void(0)">昨天</a>
                        <a class="timeList tswk" href="javascript:void(0)">本周</a>
                        <a class="timeList prwk" href="javascript:void(0)">上周</a>
                        <a class="timeList tsmonth" href="javascript:void(0)">本月</a>
                        <a class="timeList prmonth" href="javascript:void(0)">上月</a>
                    </div>
                </li>
                <li class="iList">
                    <div class="leadTxt">景点：</div>
                    <div class="countListBox">
                        <select class="selectBase w180" name="landid" id="land">  
                          <option value="0">--选择--</option>
                        </select> 
                    </div>
                    <div class="dropWrap" style="left:295px;">
                        <div class="leadTxt">门票：</div>
                        <div class="countListBox">
                            <select class="selectBase w100" id="ticket" name="ticket">
                            <option value="">--选择--</option>
                            </select> 
                        </div>
                    </div>
                </li>
                 <li class="iList fxList">
                    <div class="leadTxt">分销商</div>
                    <div class="countListBox" id="fenxiao">
                    </div>
                </li>
                <li class="iList">
                    <div class="leadTxt">统计方式：</div>
                    <div class="countListBox">
                        <select class="selectBase w180" name="by">  
                          <option value ="lid">按景区统计</option>  
                          <option value ="tid">按门票统计</option>  
                          <option value="mid">按分销商统计</option>  
                        </select> 
                    </div>
                    
                </li>
                <li class="iList">
                    <div class="countListBox">
                       <button class="searchBtn" id="search">搜 索</button>
                       <img class="loadImg" style="display:none;" src="http://images.12301.cc/icon/load.gif" />
                    </div>
                </li>
            </ul>
        </div>
        </form>
     
        <div class="tbBox">
            <table class="tbProduct" border="0" cellpadding="0" cellspacing="0">
                <thead>
                  <tr>
                    <th class="w60">序号</th>
                    <th class="setAlign">景区名称</th>
                    <th class="w60"><a href="javascript:void(0)">订单数量<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">门票数量<span class="sortBox"></span></a></th>
                    <th class="w80"><a href="javascript:void(0)">金额<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">余额支付<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">支付宝<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">授信支付<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">产品自销<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">现场支付<span class="sortBox"></span></a></th>
                    <th class="w60"><a href="javascript:void(0)">微信<span class="sortBox"></span></a></th>
                    <th class="w60"><a href="javascript:void(0)">银联<span class="sortBox"></span></a></th>
                    <th class="w60"><a href="javascript:void(0)">环讯<span class="sortBox"></span></a></th>
                    <th class="w60 lirun"><a href="javascript:void(0)">利润<span class="sortBox"></span></a></th>
                  </tr>
                   
                </thead>
                <tbody class="tbody"></tbody>
            </table>
        </div>
        <div class="tbBox topLeader">
            <table class="tbProduct" border="0" cellpadding="0" cellspacing="0">
                <thead>
                  <tr>
                    <th class="w60">序号</th>
                    <th class="setAlign">景区名称</th>
                    <th class="w60"><a href="javascript:void(0)">订单数量<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">门票数量<span class="sortBox"></span></a></th>
                    <th class="w80"><a href="javascript:void(0)">金额<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">余额支付<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">支付宝<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">授信支付<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">产品自销<span class="sortBox"></span></a></th>
                    <th class="w70"><a href="javascript:void(0)">现场支付<span class="sortBox"></span></a></th>
                    <th class="w60"><a href="javascript:void(0)">微信<span class="sortBox"></span></a></th>
                    <th class="w60"><a href="javascript:void(0)">银联<span class="sortBox"></span></a></th>
                    <th class="w60"><a href="javascript:void(0)">环讯<span class="sortBox"></span></a></th>
                    <th class="w60 lirun"><a href="javascript:void(0)">利润<span class="sortBox"></span></a></th>
                  </tr>
<!--                   <tr>
                    <td colspan="2">总计：</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                    <td>0</td>
                </tr> -->
                </thead>
            </table>
        </div>
        
        
    </div>

            
<script language="javascript" type="text/javascript" src="http://www.12301.cc/tpl/ui/My97DatePicker/My97DatePicker/WdatePicker.js"></script>


<script type="text/javascript">
    var distor_options = "";
    var supply_options = "";
    var sale_order_options_body = "";
    var buy_order_options_body = "";
    var sale_order_options_head = "";
    var buy_order_options_head = "";
    $(function(){
        //获取景点列表
        $.post("orderReport.php", {action : 'get_lands'}, function(result) {
            var options = '';
            for (var key in result) {
                options += '<option value="'+key+'" >'+result[key]+'</option>';
            }
            $("#land").append(options);
        }, "json")

        insert_distor_options();

        $(".navList").on("click", function() {
            $(".navList").removeClass('active');
            $(this).addClass('active');
            $(".tbody").empty();

            var tmp_length = $("select[name='by']").find('option').length;
            if (tmp_length == 3) {
                $("select[name='by'] > option").eq(2).remove();
            }
            if ($("thead").eq(0).find("tr").eq(1)) {
                $("thead").eq(0).find("tr").eq(1).remove();
                $("thead").eq(1).find("tr").eq(1).remove();
            } 
            if ($(this).data('type') == 'sale') {
                $(".fxList > .leadTxt").text('分销商');
                $("select[name='by']").append('<option value="mid">按分销商统计</option>');
                insert_distor_options();
                $(".tbody").html(sale_order_options_body);
                if (sale_order_options_head) {
                    $("thead").append(sale_order_options_head);
                } else {
                    $("thead").append('<tr><td colspan="2">总计：</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>');
                }
                
                $(".lirun").show();
            } else {
                $(".fxList > .leadTxt").text('供应商');
                $("select[name='by']").append('<option value="aid">按供应商统计</option>');
                insert_supply_options();
                $(".tbody").html(buy_order_options_body);
                if (buy_order_options_head) {
                    $("thead").append(buy_order_options_head);
                } else {
                    $("thead").append('<tr><td colspan="2">总计：</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>');
                }
                
                $(".lirun").hide();
            }
        })

        $("#land").on("change", function() {
            var landid = $("#land").val();
            $.post("orderReport.php", {action : 'get_tickets', landid : landid}, function(result) {
                if (result.status == 0) {
                    $("#ticket").html('<option value="0">--选择--</option>');
                    return;
                }
                var options = '<option value="0">--选择--</option>';
                var content = result.content;
                for (var i = 0; i < content.length; i++) {
                    options += '<option value="'+content[i].id+'_'+content[i].title+'">'+content[i].title+'</option>';
                }
                $("#ticket").empty();
                $("#ticket").append(options)
            }, "json")
        })

        $("#search").on('click', function() {
            var params = $("form").eq(0).serialize();
            if (params.indexOf('aid') < 0 && params.indexOf('fid') < 0) {
                return false;
            }
            params += '&action=get_reports';
            var type = $(".active").data('type');
            $(".loadImg").show();
            $.post("orderReport.php", params, function(result) {
                if (result.status == 0) {
                    var html_body = '<tr><td align="left" colspan="9">&nbsp;&nbsp;&nbsp;交易日期无销售订单！</td></tr>';
                    var html_head = '<tr><td colspan="2">总计：</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td>'
                    if (type == 'sale') {
                        html_head += '<td>0</td>';
                    } 
                    html_head += '</tr>';
                } else {
                    var content = result.info;
                    var html_body = '<tr>';
                    var html_head = '';
                    var n = 1;
                    var order_sum = 0, tnum_sum = 0, money_sum = 0, pmode0_sum = 0,
                        pmode1_sum = 0, pmode2_sum = 0, pmode3_sum = 0, pmode4_sum = 0,
                        pmode5_sum = 0, pmode7_sum = 0, pmode8_sum = 0, lirun_sum = 0;
                    for (var key in content) {
                        html_body += '<td>'+n+'</td>';
                        html_body += '<td class="setAlign">'+content[key].title+'</td>';
                        html_body += '<td>'+content[key].order+'</td>';
                        html_body += '<td>'+content[key].tnum+'</td>';
                        html_body += '<td>'+content[key].money / 100+'</td>';
                        html_body += '<td>'+content[key].pmode0 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode1 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode2 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode3 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode4 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode5 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode7 / 100+'</td>';
                        html_body += '<td>'+content[key].pmode8 / 100+'</td>';
                        if (type == 'sale') {
                            html_body += '<td>'+content[key].lirun / 100+'</td>';
                        }
                        html_body += '</tr>'
                        order_sum += parseInt(content[key].order);
                        tnum_sum += parseInt(content[key].tnum);
                        money_sum += content[key].money / 100;
                        pmode0_sum += content[key].pmode0 / 100;
                        pmode1_sum += content[key].pmode1 / 100;
                        pmode2_sum += content[key].pmode2 / 100;
                        pmode3_sum += content[key].pmode3 / 100;
                        pmode4_sum += content[key].pmode4 / 100;
                        pmode5_sum += content[key].pmode5 / 100;
                        pmode7_sum += content[key].pmode7 / 100;
                        pmode8_sum += content[key].pmode8 / 100;
                        lirun_sum += content[key].lirun / 100;
                        n++;
                    }
                    html_head += '<tr>';
                    html_head += '<td colspan="2">总计：</td>';
                    html_head += '<td>'+order_sum+'</td>';
                    html_head += '<td>'+tnum_sum+'</td>';
                    html_head += '<td>'+money_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode0_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode1_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode2_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode3_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode4_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode5_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode7_sum.toFixed(2)+'</td>';
                    html_head += '<td>'+pmode8_sum.toFixed(2)+'</td>';
                    if (type == 'sale') {
                        html_head += '<td>'+lirun_sum.toFixed(2)+'</td>';
                    }
                    html_head += '</tr>';
                }
                if (type == 'sale') {
                    sale_order_options_body = html_body;
                    sale_order_options_head = html_head;
                } else {
                    buy_order_options_body = html_body;
                    buy_order_options_head = html_head;
                }
                if ($("thead").eq(0).find("tr").eq(1)) {
                    $("thead").eq(0).find("tr").eq(1).remove();
                    $("thead").eq(1).find("tr").eq(1).remove();
                } 
                $("thead").append(html_head);
                $(".tbody").html(html_body);
                $(".loadImg").hide();
            }, "json")            
            return false;
        })
    })

    function insert_distor_options() {
        $("#fenxiao").empty();
        if (distor_options) {
            $("#fenxiao").append(distor_options);
            return ;
        }
        $.post("orderReport.php", {action : 'get_distors'}, function(result) {
            distor_options = combine_options(result, 'fid');
            $("#fenxiao").append(distor_options);
        }, "json")
    }

    function insert_supply_options() {
        $("#fenxiao").empty();
        if (supply_options) {
            $("#fenxiao").append(supply_options);
            return ;
        }
        $.post("orderReport.php", {action : 'get_supllys'}, function(result) {
            supply_options = combine_options(result, 'aid');
            $("#fenxiao").append(supply_options);
        }, "json")
    }

    function combine_options(result, name) {
        var tmp = []
        for (var key in result) {
            tmp.push(result[key] + '|*|' + key)
        }
        tmp.sort();
        var options = '<select name="'+name+'" class="selectBase w180"><option value="0">--选择--</option>';
        for (var i = 0; i < tmp.length; i++) {
            var tmp_arr = tmp[i].split('|*|');
            options += '<option value="'+tmp_arr[1]+'">'+tmp_arr[0]+'</option>';
        }
        options += "</select>";
        return options;
    }
  
       
    $(window).scroll(function(){
        var wh=$(document).scrollTop();
        if(wh>590){
            $(".conWrap .tbBox.topLeader").show();
        }else{
            $(".conWrap .tbBox.topLeader").hide();
        }
    })
   
</script>
    
</body>
</html>